package com.ruoyi.audit.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.HomeRecyclingDetailOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.audit.service.IHomeRecyclingDetailOrderService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 上门回收审核Controller
 * 
 * @author ruoyi
 * @date 2021-03-24
 */
@RestController
@RequestMapping("/recycling")
public class HomeRecyclingDetailOrderController extends BaseController
{
    @Autowired
    private IHomeRecyclingDetailOrderService homeRecyclingDetailOrderService;

    /**
     * 查询上门回收审核列表
     */
    @PreAuthorize(hasPermi = "audit:recycling:list")
    @GetMapping("/list")
    public TableDataInfo list(HomeRecyclingDetailOrder homeRecyclingDetailOrder)
    {
        startPage();
        List<HomeRecyclingDetailOrder> list = homeRecyclingDetailOrderService.selectHomeRecyclingDetailOrderList(homeRecyclingDetailOrder);
        return getDataTable(list);
    }

    /**
     * 导出上门回收审核列表
     */
    @PreAuthorize(hasPermi = "audit:recycling:export")
    @Log(title = "上门回收审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeRecyclingDetailOrder homeRecyclingDetailOrder) throws IOException
    {
        List<HomeRecyclingDetailOrder> list = homeRecyclingDetailOrderService.selectHomeRecyclingDetailOrderList(homeRecyclingDetailOrder);
        ExcelUtil<HomeRecyclingDetailOrder> util = new ExcelUtil<HomeRecyclingDetailOrder>(HomeRecyclingDetailOrder.class);
        util.exportExcel(response, list, "recycling");
    }

    /**
     * 获取上门回收审核详细信息
     */
    @PreAuthorize(hasPermi = "audit:recycling:query")
    @GetMapping(value = "/{detailorderid}")
    public AjaxResult getInfo(@PathVariable("detailorderid") Long detailorderid)
    {
        return AjaxResult.success(homeRecyclingDetailOrderService.selectHomeRecyclingDetailOrderById(detailorderid));
    }

    /**
     * 新增上门回收审核
     */
    @PreAuthorize(hasPermi = "audit:recycling:add")
    @Log(title = "上门回收审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomeRecyclingDetailOrder homeRecyclingDetailOrder)
    {
        return toAjax(homeRecyclingDetailOrderService.insertHomeRecyclingDetailOrder(homeRecyclingDetailOrder));
    }

    /**
     * 修改上门回收审核
     */
    @PreAuthorize(hasPermi = "audit:recycling:edit")
    @Log(title = "上门回收审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomeRecyclingDetailOrder homeRecyclingDetailOrder)
    {
        return toAjax(homeRecyclingDetailOrderService.updateHomeRecyclingDetailOrder(homeRecyclingDetailOrder));
    }

    /**
     * 删除上门回收审核
     */
    @PreAuthorize(hasPermi = "audit:recycling:remove")
    @Log(title = "上门回收审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailorderids}")
    public AjaxResult remove(@PathVariable Long[] detailorderids)
    {
        return toAjax(homeRecyclingDetailOrderService.deleteHomeRecyclingDetailOrderByIds(detailorderids));
    }
}
